#include "pch.h"

Ground::Ground()
{
	
}

Ground::~Ground()
{
	
}

void Ground::OnUpdate(float frameTime)
{
	
}

void Ground::OnPreRender()
{
	if(m_GroundSprite)
	{
		//b2Vec2 p = m_b2BodyGround->GetPosition();
		//m_GroundSprite->SetPosition(float2(p.x, p.y));
		m_GroundSprite->PreRender(RenderObjectManager::RenderObjectLayer0);
	}
}

void Ground::Initialize()
{
	BodyInfo b_info;
	b_info.owner_point = this;
	b_info.entity_type = Object_Ground;
	b_info.entity_bodytype = b2_staticBody;
	
	b2Transform t;
	t.p = b2Vec2(0.f, -1.f);
	t.q.SetIdentity();
	float2 ground_size = float2(20.f, 0.1f);
	Box2DManager::Instance()->CreateBox(b_info, m_b2BodyGround, t, CovertSizeR2B(ground_size), 0.f);
	m_b2BodyGround->SetActive(true);

	m_GroundSprite = RenderObjectManager::Instance()->CreateSprite(L"data/texture.dds", float2(0, -1.f), ground_size);
}